package com.yyfax.pay.order.model.vo;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.io.xml.QNameMap;
import com.thoughtworks.xstream.io.xml.StaxDriver;
import com.thoughtworks.xstream.io.xml.StaxWriter;

import java.io.Serializable;
import java.io.StringWriter;

@XStreamAlias("ORDER")
public class ProtocolPayQueryVO implements Serializable {

    @XStreamAlias("VERSION")
    private String version;

    @XStreamAlias("MCHNTCD")
    private String merchantCode;

    @XStreamAlias("MCHNTORDERID")
    private String busiId;

    @XStreamAlias("SIGN")
    private String sign;


    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getMerchantCode() {
        return merchantCode;
    }

    public void setMerchantCode(String merchantCode) {
        this.merchantCode = merchantCode;
    }

    public String getBusiId() {
        return busiId;
    }

    public void setBusiId(String busiId) {
        this.busiId = busiId;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String toXml() {
        QNameMap qmap = new QNameMap();
        qmap.setDefaultPrefix("");
        StaxDriver staxDriver = new StaxDriver(qmap);
        XStream xstream = new XStream(staxDriver);
        xstream.autodetectAnnotations(true);
        xstream.ignoreUnknownElements();
        xstream.alias("ORDER", ProtocolPayQueryVO.class);
        try {
            StringWriter strWriter = new StringWriter();
            StaxWriter sw = new StaxWriter(staxDriver.getQnameMap(), staxDriver.getOutputFactory().createXMLStreamWriter(strWriter), false, true);
            xstream.marshal(this, sw);
            sw.close();
//            return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"+ strWriter.toString();
            return strWriter.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
